package com.yugao.fintech.antelope.shop.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yugao.fintech.antelope.base.security.annotation.InnerAuth;
import com.yugao.fintech.antelope.base.model.module.auth.LoginUser;
import com.yugao.fintech.antelope.base.ram.ActionType;
import com.yugao.fintech.antelope.base.ram.RamResource;
import com.yugao.fintech.antelope.shop.model.rqrs.UmsMemberPageReq;
import com.yugao.fintech.antelope.shop.model.rqrs.UmsMemberReq;
import com.yugao.fintech.antelope.shop.model.rqrs.UmsMemberResp;
import com.yugao.fintech.antelope.shop.model.rqrs.UserStatusUpdateReq;
import com.yugao.fintech.antelope.shop.process.FumUserProcess;
import com.yugao.fintech.antelope.shop.service.UmsMemberService;
import com.yugao.fintech.antelope.system.model.rqrs.log.LoginUserGetReq;
import com.yugao.fintech.framework.core.response.Resp;
import com.yugao.fintech.framework.validation.group.UpdateGroup;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;

/**
 * 前台用户
 * @deprecated
 
 */
@Api(tags = "前台用户")
@RestController
@RequestMapping("/umsMember")
public class UmsMemberController {
    @Autowired
    private UmsMemberService umsMemberService;
    @Autowired
    private FumUserProcess fumUserProcess;

    @InnerAuth
    @PostMapping(value = "/getLoginUser")
    public Resp<LoginUser> getLoginUser(@RequestBody LoginUserGetReq req) {
        LoginUser loginUser = fumUserProcess.getLoginUser(req);
        return Resp.ok(loginUser);
    }
  
    /**
     * 分页 前台用户
     */
    @GetMapping("/pageUser")
    public Resp<IPage<UmsMemberResp>> pageUser(@Validated UmsMemberPageReq query) {
        return Resp.ok(umsMemberService.pageUser(query));
    }
  
    /**
     * 通过id查找 前台用户
     */
    @GetMapping("/getUserById")
    public Resp<UmsMemberResp> getUserById(@RequestParam(value = "id") Long id) {
        return Resp.ok(umsMemberService.getUserById(id));
    }
  
    /**
     * 更新 前台用户
     */
    @PostMapping("/updateUserById")
    public Resp<?> updateMemberById(@Validated(UpdateGroup.class) @RequestBody UmsMemberReq rq) {
        return Resp.ok(umsMemberService.updateUserById(rq));
    }

    /**
     * 批量更新用户状态
     */
    @RamResource(action = "portal:user:freeze", name = "更新会员用户状态", type = ActionType.WRITE)
    @PostMapping("/batchUpdateStatus")
    public Resp<?> batchFreezeUser(@RequestBody @Validated UserStatusUpdateReq rq) {
        umsMemberService.batchUpdateStatus(rq);
        return Resp.ok();
    }
}
